#!/bin/bash

net::is_github_visitable() {
  curl -I https://github.com --connect-timeout 3 >>/dev/null 2>&1
  if [ "$?" != "0" ]; then
    echo "false"
  else
    echo "true"
  fi
}

net::is_google_visitable() {
  curl -I https://google.com --connect-timeout 3 >>/dev/null 2>&1
  if [ "$?" != "0" ]; then
    echo "false"
  else
    echo "true"
  fi
}

net::is_in_china() {
  if [ "$(net::is_google_visitable)" = "false"]; then
    echo "true"
  else
    echo "false"
  fi
}

export -f net::is_in_china
export -f net::is_github_visitable
export -f net::is_google_visitable
